//  IDVI 1.0 source copyright 1996 Garth A. Dickie
//
//  This source is free for non-commercial use.  No warranty, etc.
//  Please acknowledge reuse by including the line:
//
//  "Based in part on IDVI 1.0 source copyright 1996 Garth A. Dickie"
//
//  in your documentation and source code.  For commercial use or
//  distribution, please contact the author.  Please also send
//  questions, comments, bug reports, or fixes.
//
//  Best Regards,
//  Garth A. Dickie
//  dickie@elastic.avid.com

package ibook.v10.idvi.dvi;

public class DVIFormatException extends Exception {
    public DVIFormatException( ) {
        super( );
    }

    public DVIFormatException( String s ) {
        super( s );
    }

    public DVIFormatException( DVIFormatException e, String fileName ) {
        super( specifyFileName( e.getMessage( ), fileName ));
    }

    private static String specifyFileName( String message, String fileName ) {
        int percentIndex = message.indexOf( '%' );

        if( percentIndex >= 0 )
            return message.substring( 0, percentIndex ) + '"' + fileName + '"' + message.substring( percentIndex + 1 );
        else
            return message;
    }
}
